package com.maybach.workflow.common;

import com.maybach.util.AssertUtil;
import com.maybach.workflow.common.api.FlowHandlerFactory;
import com.maybach.workflow.common.api.IFlowHandler;
import org.springframework.beans.factory.InitializingBean;

/**
 * Created by houenxun on 16/1/28.
 */
public abstract class AbstractHanlder implements IFlowHandler, InitializingBean {


    @Override
    public void afterPropertiesSet() throws Exception {
        register();
    }

    protected void register() {
        String key = this.getHandlerKey();
        AssertUtil.notBlank(key, "key");
        FlowHandlerFactory.register(key, this);
    }

    /**
     * 返回注册的key
     * @return
     */
    abstract    protected String getHandlerKey();
}
